package com.hzsai.web.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author hzsai
 * @date 2020/2/20 22:07
 * @usage:
 */
@WebServlet(urlPatterns = "/my/servlet")
public class MyServlet extends HttpServlet {

    /**
     * 这里，实现一个servlet的流程
     * 1. 继承HttpServlet，覆写相关的方法，如doGet; 类上添加@WebServlet注解
     * 2. 路径映射，在@WebServlet里添加映射的路径
     * 3. servlet注册 @ServletComponentScan
     */
    /**
     *
     * @param req
     * @param resp
     * @throws ServletException
     * @throws IOException
     */

    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        resp.getWriter().println("Hello, Servlet");
    }
}
